package com.zmy.springboot.service.Impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zmy.springboot.bean.AccountSearch;
import com.zmy.springboot.bean.PublicAccount;
import com.zmy.springboot.dao.PublicAccountDAO;
import com.zmy.springboot.service.PublicAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @PROJECT_NAME：springboot+thymeleaf-1-7
 * @author： zhangyaoyao
 * @date： 2020/1/7 22:31
 * @ 听说你要在海边买一所房子和 你可爱的松子一起住在哪里
 */
@Service
public class PublicAccountServiceImpl implements PublicAccountService {
    @Autowired
    private PublicAccountDAO publicAccountDAO;
    @Override
    public PublicAccount getPublicAccountById(Integer id) {
        return publicAccountDAO.getPublicAccountById(id);
    }

    @Override
    public int updatePublicAccount(PublicAccount publicAccount) {

        return publicAccountDAO.updatePublicAccount(publicAccount);
    }

    @Override
    public PageInfo<PublicAccount> getPublicAccountList(Integer pageIndex,Integer pageSize,AccountSearch accountSearch) {
        PageHelper.startPage(pageIndex,pageSize);
        List<PublicAccount> publicAccountList = publicAccountDAO.getPublicAccountList(accountSearch);
        return  new PageInfo<>(publicAccountList,5);
    }
}
